import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },

  {
    path: '/Index',
    name: 'index',
    component: () => import('../views/IndexView.vue'),
    children: [
      {
        path: '/Home',
        name: 'home',
        mete: {
          title: '首页'
        },
        component: () => import('../views/HomeView.vue')
      },
      {
        path: '/User',
        name: 'user',
        mete: {
          title: '用户管理'
        },
        component: () => import('../components/Admin/UserManage.vue')
      },
      {
        path: '/Grad',
        name: 'grad',
        mete: {
          title: '毕设管理'
        },
        component: () => import('../components/Admin/GradManage.vue')
      },
      {
        path: '/Scores',
        name: 'scores',
        mete: {
          title: '成绩管理'
        },
        component: () => import('../components/Admin/ScoresManage.vue')
      },
      {
        path: '/Register',
        name: 'Register',
        mete: {
          title: '毕设登记'
        },
        component: () => import('../components/Student/RegisterView.vue')
      },
      {
        path: '/GradeS',
        name: 'GradeSearch',
        mete: {
          title: '成绩查询'
        },
        component: () => import('../components/Student/GradeSearchView.vue')
      },
      {
        path: '/AssessG',
        name: 'AssessGrade',
        mete: {
          title: '成绩评定'
        },
        component: () => import('../components/Teacher/AssessGradeView.vue')
      },

    ]
  },


]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export function resetRouter() {
  router.matcher = new VueRouter({
    mode: 'history',
    routes: []
  }).matcher
}
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router
